<template>
	<view class="count">
		<view class="top">

		</view>
		<!-- <image src="/static/code.png"  mode=""></image> -->
		<canvas id="qrcode" class="code" canvas-id="qrcode"></canvas>
		<view class="return">
			用于归还时扫码
		</view>
	</view>
</template>

<script>
	import UQRCode from '@/uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
	export default {
		data() {
			return {
				code: ''
			}
		},
		onLoad(options) {
			this.code = options.code
			// this.initObj()
			this.codes()
		},
		methods: {
			codes() {
				var qr = new UQRCode();
				// 设置二维码内容
				qr.data = this.code;
				// 设置二维码大小，必须与canvas设置的宽高一致
				qr.size = 200;
				// 调用制作二维码方法
				qr.make();
				// 获取canvas上下文
				var canvasContext = uni.createCanvasContext('qrcode', this); // 如果是组件，this必须传入
				// 设置uQRCode实例的canvas上下文
				qr.canvasContext = canvasContext;
				// 调用绘制方法将二维码图案绘制到canvas上
				qr.drawCanvas();
			},
			// async initObj() {
			// 	let n = await this.$api.BorrowsJie({
			// 		book_no: this.code
			// 	})
			// }
		}
	}
</script>

<style lang="scss" scoped>
	.top {
		height: 50rpx;
		width: 100%;
	}

	.return {
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #999999;
	}

	.code {
		width: 376rpx;
		height: 376rpx;
		margin-left: 50%;
		transform: translateX(-50%);
		margin-bottom: 50rpx;
	}

	.count {
		height: 100vh;
		width: 100%;
		background-color: #fff;
	}
</style>